package SilkTest::TestPlan;
use strict; use warnings;
use Data::Dump qw /dump/;

sub new {
    my $class = shift;
    my $this = {
                    TREE => {}
               };
    bless $this, $class;
}

sub parse {
    my ( $this, $file_name ) = @_;
    open (FV, "<$file_name") or die ("Unable to open file $file_name");
    my @content = <FV>;
    close FV;

    my $root = SilkTest::Line->new("", -1, -1);
    $this->{root} = $root;
    $root->is_block(1);
    $root->set_content("ROOT");
    my $current_block = $root;
    my $included_lines = 0;
    my $prev_line = $root;
    
    for ( my $i = 0; $i < @content; $i++ ) {
        my $l = $content[$i];
        my $line = SilkTest::PlanParser::Line->new($l, $i - $included_lines, $i);
        $line->register($prev_line, $current_block);
        my $content = $line->content;
        
        # Check for variables
        if ( $content !~ m!\s*//! && $content =~ m/([^\$]?\$\w+)\s*=(.*)/ ) {
            my ($variable, $value) = ($1, $2);
            $current_block->parse_variable($variable, $value);
        }
        $prev_line = $line;
    }

}

sub root { shift->{root} };

1; # End of package SilkTest::PlanParser



